package cn.sowfin.controller;

import cn.sowfin.dao.UserDao;

import cn.sowfin.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

@Controller
public class LoginController {
    @Autowired
    RedisTemplate redisTemplate;

    @GetMapping("register")
    public String register(){

        return "register";

    }
    @GetMapping("login")
    public String login(User user){

        redisTemplate.opsForValue().set(user.getUsername(),user.getPassword());
        return "login";
    }
    @GetMapping("islogin")
    public String islongin(User user){


        User user1=(User) redisTemplate.opsForValue().get(user.getUsername());

        if(user1!=null){

            return "index";
        }else{
            return "login";
        }


    }








}
